﻿using Autofac;
using Behaviorize.CodeGenerator.FileIO;
using Behaviorize.CodeGenerator.VsProject;

namespace Behaviorize.CodeGenerator
{
	public static class ServiceLocator
	{
		private static IContainer _container;

		public static IContainer Container
		{
			get
			{
				if (_container == null)
				{
					var builder = new ContainerBuilder();
					builder.RegisterType<FileWriter>().As<IFileWriter>();
					builder.RegisterType<FileReader>().As<IFileReader>();
					builder.RegisterType<ProjectItemService>().As<IProjectItemService>();
					_container = builder.Build();
				}
				return _container;
			}
			set { _container = value; }
		}

		public static T Resolve<T>()
		{
			return Container.Resolve<T>();
		}
	}
}